'use strict';
var Schema = require('mongoose').Schema,
    CommonEnum = require('../controllers/Enum.js'),
    Model = require('../../../Base/server/controllers/Model');

var modelField = {
    Code: {
        type: String,
        trim: true,
        Name: '编码',
        IsUnique: true,
        IsEmpty: false      
    },
    Name: {
        type: String,
        Name: '名称',
        IsEmpty: false,
        trim: true
    },
    ScheduleProgram: {
        type: Schema.ObjectId,
        ref: 'ScheduleProgram',
        Name: '调度方案',
        IsEmpty: false
    },
    Scheduler: {
        type: Schema.ObjectId,
        ref: 'Scheduler',
        Name: '调度程序',
        IsEmpty: false
    },
    Status: {
        type: Number,
        Name: '状态',
        IsEmpty: false,
        Enum: CommonEnum.ScheduleStatus
    },
    Submitter: {
        type: String,
        Name: '提交人',
        trim: true
    },
    CancelPerson: {
        type: String,
        Name: '取消人',
        trim: true
    },
    LastRequestTime: {
        type: Date,
        Name: '最后请求时间'
    },
    CancelTime: {
        type: Date,
        Name: '取消时间'
    },
    ExecuteTimes: {
        type: Number,
        Name: '执行次数'
    },
    Remark: {
        type: String,
        Name: '备注',
        default: '',
        trim: true
    }
};

var newModel = new Model(modelField);
newModel.addIndex({Name: 1});
newModel.addIndex({Code: 1});
newModel.create('ScheduleRequest', '调度请求');
